package br.com.treinaweb.parte2;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class Tela2 extends Activity implements OnClickListener{
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);	
		setContentView(R.layout.activity_tela2);
		
		Intent intencao = getIntent();
		Bundle extras = intencao.getExtras();
		if (extras == null) return;
		
		String nome = extras.getString("nome");
		if (nome != null) {
			TextView tTitulo = (TextView) findViewById(R.id.textViewResposta);
			tTitulo.setText(nome + ", digite algo abaixo:");
		}
		
		Button btnVoltar = (Button) findViewById(R.id.buttonVoltar);
		btnVoltar.setOnClickListener(this);
	}
	
	@Override
	public void onClick (View v) {
		Intent data = new Intent();
		EditText eTexto = (EditText) findViewById(R.id.editTextTexto);
		String texto = eTexto.getText().toString();
		
		data.putExtra("texto", texto);
		setResult(RESULT_OK,data);
		
		finish();
	}
}
